<?php

declare(strict_types=1);

namespace Modules\Warehouse\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $owning_id
 * @property $warehousecode
 * @property $repositoryname
 * @property $remarks
 * @property $person
 * @property $modifier
 * @property $modi_time
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class Storagelocation extends Model
{


    protected $table = 'storagelocation';

    protected $fillable = [ 'id', 'owning_id', 'warehousecode', 'repositoryname', 'remarks', 'person', 'modifier', 'creator_id', 'created_at', 'updated_at', 'deleted_at' ];

    /**
     * @var array 列表输出的字段
     */
    protected array $fields = ['id','owning_id','warehousecode','repositoryname','remarks','person','modifier','created_at','updated_at', 'creator_id'];

    /**
     * @var array
     */
    protected array $form = ['id','owning_id','warehousecode','repositoryname','remarks','person','modifier','updated_at','created_at', 'creator_id'];

    /**
     * @var array
     */
    
    public array $searchable = [
        'warehousecode' => '=',
        'repositoryname' => 'like',
        'remarks' => 'like',
        'owning_id' => '=',
    ];

    //输出相应的时间格式
    protected function serializeDate($date)
    {
        // return $date->format('Y-m-d H:i');

    return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');

    }

    /**
     * 关联仓库信息
     * @return mixed
     */
    public function wms()
    {
        return $this->hasOne(Stash::class,'id','owning_id');
    }

}
